package com.kabigon.tiny;

import com.kabigon.tiny.config.ApplicationConfig;
import com.kabigon.tiny.domain.User;
import com.kabigon.tiny.event.UserRegisterEvent;
import com.kabigon.tiny.event.UserRegisterEventListener;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * @author xu.biao
 * @version v1.0
 * @Package com.kabigon.tiny
 * @data 2023/4/19 23:41
 */
public class EventStart {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(ApplicationConfig.class);
        UserRegisterEventListener userRegisterEventListener = applicationContext.getBean("userRegisterEventListener", UserRegisterEventListener.class);
        // 获取容器里注册的 UserRegisterEvent bean
        User user = new User();
        user.setName("kabigon");
        user.setEmail("123@163.com");
        user.setAddress("上海");
        applicationContext.publishEvent(new UserRegisterEvent(user));
    }

}
